package miracle.joker.design.iterator;

import java.util.Iterator;

public class IteratorDemo {

    public static void main(String[] args) {
        // 创建电影库对象
        MovieLibrary movieLibrary = new MovieLibrary();

        // 添加电影
        movieLibrary.addMovie(new Movie("The Shawshank Redemption", "Frank Darabont", 1994));
        movieLibrary.addMovie(new Movie("The Godfather", "Francis Ford Coppola", 1972));
        movieLibrary.addMovie(new Movie("The Dark Knight", "Christopher Nolan", 2008));

        // 遍历电影库并输出电影信息
        Iterator<Movie> iterator = movieLibrary.iterator();
        while (iterator.hasNext()) {
            Movie movie = iterator.next();
            System.out.println(movie.getName() + " - " + movie.getDirector() + " - " + movie.getYear());
        }
    }
}
